import { http } from '@/utils/axios';
import { Base } from '@/types/modules/base';

const Api = {
  createMenuRel: '/v1/basic/role/create-menu-rels',
  queryMenuRel: '/v1/basic/role/query-menu-rels',
  page: '/v1/basic/role/page',
  list: '/v1/basic/role/list',
  create: '/v1/basic/role/create',
  modify: '/v1/basic/role/modify',
  remove: '/v1/basic/role',
  detail: '/v1/basic/role/detail',
};

export function createMenuRel(data: Role.RoleMenuRel) {
  return http.request({
    url: Api.createMenuRel,
    method: 'POST',
    data,
  });
}

export function queryMenuRel(id: string) {
  return http.request<Role.RoleMenuRel>({
    url: `${Api.queryMenuRel}/${id}`,
    method: 'GET',
  });
}

export function detail(id: string) {
  return http.request<Role.RoleInfoTO>({
    url: `${Api.detail}/${id}`,
    method: 'GET',
  });
}

export function page(data: Role.QueryRoleReq) {
  return http.request<Base.PageResult<Role.RoleInfoTO>>({
    url: Api.page,
    method: 'POST',
    data,
  });
}

export function list() {
  return http.request<Role.RoleInfoTO[]>({
    url: Api.list,
    method: 'GET',
  });
}

export function create(data: Role.RoleInfoTO) {
  return http.request({
    url: Api.create,
    method: 'POST',
    data,
  });
}

export function modify(data: Role.RoleInfoTO) {
  return http.request({
    url: Api.modify,
    method: 'POST',
    data,
  });
}

export function remove(id: string) {
  return http.request({
    url: `${Api.remove}/${id}`,
    method: 'DELETE',
  });
}
